home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
bor_ti.exe
/
TI1158.ASC
< prev
next >
Wrap
Text File
|
1992-11-11
|
15KB
|
595 lines
PRODUCT : Borland C++ NUMBER : 1158
VERSION : 3.1
OS : DOS
DATE : November 11, 1992 PAGE : 1/9
TITLE : A modal dialog from a modal dialog with Turbo Vision
The following code provides an example of executing a Modal
Dialog Box from another Dialog Box when using Turbo Vision.
/*********************************************************************\
* TEST.CPP *
* This module contains the Turbo Vision application code to run *
* this example. It sets up the necessary menus to bring up the *
* test module represented by this demo. *
* *
* TEST MODULE for Dialog Example #3 : Creating a second modal dialog*
* box from within a first. *
* *
*********************************************************************
* *
* This code was written by Borland Technical Support. *
* It is provided as is with no warranties expressed or implied. *
* *
\*********************************************************************/
#define Uses_TRect
#define Uses_TKeys
#define Uses_TEvent
#define Uses_TDialog
#define Uses_TMenu
#define Uses_TMenuItem
#define Uses_TMenuBar
#define Uses_TDeskTop
#define Uses_TApplication
#include <tv.h>
#include <mem.h>
#pragma hdrstop
#include "cmds.h"
#include "mdlg.h"
class TTestApp : public TApplication
{
public:
PRODUCT : Borland C++ NUMBER : 1158
VERSION : 3.1
OS : DOS
DATE : November 11, 1992 PAGE : 2/9
TITLE : A modal dialog from a modal dialog with Turbo Vision
TTestApp() : TApplication(),
TProgInit( initStatusLine, initMenuBar, initDeskTop )
{ }
static TMenuBar *initMenuBar( TRect r );
virtual void handleEvent( TEvent& event );
};
TMenuBar *TTestApp::initMenuBar( TRect r )
{
r.b.y = r.a.y + 1;
return new TMenuBar( r, new TMenu(
*new TMenuItem( "~D~ialog Box", cmEDialog, kbAltE )
));
}
void TTestApp::handleEvent( TEvent& event )
{
TFirstDialog *td;
TApplication::handleEvent( event );
if( event.what == evCommand &&
event.message.command == cmEDialog )
{
td = new TFirstDialog( TRect(0,0,40,11),
"The first dialog box." );
if( validView( td ) )
deskTop->execView( td );
}
}
int main()
{
TTestApp TB;
TB.run();
return 0;
}
PRODUCT : Borland C++ NUMBER : 1158
VERSION : 3.1
OS : DOS
DATE : November 11, 1992 PAGE : 3/9
TITLE : A modal dialog from a modal dialog with Turbo Vision
/*********************************************************************
* *
* MDLG.CPP *
* This module contains the code for the two subclassed dialogs use*
* by this demo. *
* *
* SUPPORT MODULE for dialog example #3 : Creating a second modal *
* dialog box from within a first. *
* *
* The key to this operation is making sure that the deskTop's *
* execView() function is used in all cases when a modal dialog box*
* is desired. execView() is a member function of TGroup, thus any*
* class derived from TGroup will have its own version of that *
* function. When inside a dialog box handleEvent procedure, code *
* such as *
* *
* TDialog *td = ... *
* execView( td ); *
* *
* will compile, but the box will come up with lots of flashing *
* white on red colors. This is because the new dialog box was *
* inserted into the old dialog box, instead of the deskTop and the*
* palette isn't mapped right. The solution is to execView the *
* dialog box this way: *
* *
* TDialog *td = ... *
* TProgram::deskTop->execView( td ); *
* *
* 'deskTop' is a static public member of TProgram and points to the*
* desktop object of the current application. This way, the dialog*
* box will be inserted into the desktop and the palettes will work*
* properly. The Z order will also be correct so that the views *
* stack up right. *
* *
*********************************************************************
* *
* This code was written by Borland Technical Support. *
* It is provided as is with no warranties expressed or implied. *
* *
*********************************************************************/
#define Uses_TRect
#define Uses_TKeys
PRODUCT : Borland C++ NUMBER : 1158
VERSION : 3.1
OS : DOS
DATE : November 11, 1992 PAGE : 4/9
TITLE : A modal dialog from a modal dialog with Turbo Vision
#define Uses_TEvent
#define Uses_TButton
#define Uses_TStaticText
#define Uses_TDialog
#define Uses_MsgBox
#define Uses_TDeskTop
#define Uses_TProgram
#include <tv.h>
#pragma hdrstop
#include "cmds.h"
#include "mdlg.h"
/********************************************************************
* Class TFirstDialog *
********************************************************************
* TFirstDialog::TFirstDialog *
* Constructor for the dialog box. Encapsulates the box to ease *
* creation. *
********************************************************************/
TFirstDialog::TFirstDialog( TRect& r, char *aTitle ) :
TDialog( r, aTitle ),
TWindowInit( initFrame )
{
insert( new TStaticText( TRect(2,2,38,6),
"This is a modal dialog box. Hitting the <More> button below "
"will bring up a second modal dialog box on top of this one."
));
insert( new TButton( TRect(2,8,12,10),
"~M~ore", cmMore, bfDefault )
);
insert( new TButton( TRect(14,8,24,10), "O~K~", cmOK, bfNormal )
);
insert( new TButton( TRect(26,8,36,10), "~C~ancel", cmCancel,
bfNormal )
);
selectNext( False );
options |= ofCentered;